package com.polymorphic.polyexercise;

/**
 * @Author 小闽
 * @Date 2024/8/12 17:06
 * @PackageName: com.polymorphic.polyexercise
 * @ClassName: PolyExercise01
 * @Description: 多态练习
 * @Version 1.0
 */
public class PolyExercise01 {
    public static void main(String[] args) {
        double d = 13.4;
        long l = (long)d; // 将d强制转换为long,即运行类型为long类型
        System.out.println(l);  // 输出13
//        int in = 5;
//        boolean b = (boolean)in;
        Object obj = "hello"; // 向上转型
        String objStr = (String)obj; // 向下转型
        System.out.println(objStr); // 输出 hello
        Object objPri = new Integer(5); // 向上转型
//        String str = (String)objPri;
        Integer str1 = (Integer)objPri; // 向下转型
        System.out.println(str1); // 输出5
    }
}
